#!/usr/bin/env python
#-*- coding:utf-8 -*-

'''
计算器
'''
import types
import sys
def calculator(express):
    'exrepsss ： 计算表达式 eg:1 + 1'
    if type(express) is not types.StringType: return 0 
    exs = express.split(' ')
    if len(exs) != 3 : return 1 
    opers = ['+', '-', '*', '/', '%', '**']
    oper = exs[1]
    if oper not in opers : return 2 
    result = 0
    exs[0] = int(exs[0])
    exs[2] = int(exs[2])
    if(oper == opers[0]): #这里可以用更高级的用法，这里暂时先用这个
        result = add(exs[0], exs[2])
    elif(oper == opers[1]):
        result = reduce_num(exs[0], exs[2])
    elif(oper == opers[2]):
        result = mul(exs[0], exs[2])
    elif(oper == opers[3]):
        result = div(exs[0], exs[2])
    elif(oper == opers[4]):
        result = mod(exs[0], exs[2])
    else:
        result = pow_num(exs[0], exs[2])
    return result


def add(num1, num2):
    return num1 + num2

def reduce_num(num1, num2):
    return num1 - num2

def mul(num1, num2):
    return num1 * num2

def div(num1, num2):
    return num1 / num2

def mod(num1, num2):
    return num1 % num2

def pow_num(num1, num2):
    return num1 ** num2
    

if __name__ == '__main__':
    args = sys.argv
#    a = 10
#    b = 2
    express = args[1]
    result = calculator(express)
    print ''.join((express , ' = %s '  % (result)))#避免使用" + "，可以提高字符川操作性能


